package com.xxx.common.web.exception;



import lombok.Getter;
import lombok.Setter;


@Getter
@Setter
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误信息
     */
    private String message;

    /**
     * 异常堆栈
     */
    private String stackTraceMsg;

    private BusinessException() {
    }

    public BusinessException(String message) {
        super(message);
        this.message = message;
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public BusinessException(String code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BusinessException(String code, String message, Throwable cause) {
        super(message, cause);
        this.message = message;
        this.code = code;
    }

    public BusinessException(String code, String message, String stackTraceMsg) {
        super(message, new RuntimeException(stackTraceMsg));
        this.code = code;
        this.message = message;
        this.stackTraceMsg = stackTraceMsg;
    }

    public BusinessException(BaseErrorCode baseErrorCode) {
        super(baseErrorCode.getMessage());
        this.message = baseErrorCode.getMessage();
        this.code = baseErrorCode.getCode();
    }

}
